;:sys36864
	*= $c000
	;.opt oo
vic	=53248
cint	=65409
tmp	=2
tmp2	=4
irqvec	=$314
ciaclr	=$dc0d
zeile1	=40
zeile2	=114
endirq	=$ea81
bsout	=$ffd2
spalte	=211
konf	=1
get	=65508
keyrep	=650
input	=65487
key	=198
keybuf	=631
loadr	=$ffd5
setnam	=$ffbd
fa	=$ba
sa	=$b9
clrx	=59903
saver	=$ffd8
	jmp begin
met	.byte "\x1a\x13\x19\x09\x11\x9b\x12 the nss font grabber v1 [c] nss 020887"
	.byte " \x1a (+) 1 font forward\x18(-) 1 font rewind"
	.byte "\x1a (>) 1 byte forward\x18(<) 1 byte rewind"
	.byte "\x1a (l) oad font\x18(s) ave font"
	.byte "\x1a (e) xit\x18(r) estart"
	.byte "\x1a (i) nvert all\x18(m) ake 2nd half"
	.byte "\x1a (k) onfiguration\x18(h) ires/multicol"
	brk
adrline	.byte "\x1a\x13\x19\x12\x11\x12 font adress: $\x19\x07 konfiguration: $  \x9d\x9d"
	brk
namtxt	.byte "\x1a\x13\x19\x14\x11filename ? "
	brk
hexnum	.byte "0123456789abcdef"
menuchr	.byte "erk+-im.,><hls"
menuadr	 .word exit,restart,makekonf,plus,minus,invall
	.word make2,pbyt,mbyt,pbyt,mbyt,swmode,load,save
buftxt	.byte "zs."
oldirq	.word $ea31
char	brk
konfig	brk
mem	.word 0
mode	brk
filename	.word 0,0,0,0,0,0,0,0
begin	jsr init
menu	jsr get
	beq menu
	ldx #menuadr-menuchr-1
menusuch	cmp menuchr,x
	beq foundmen
	dex
	bpl menusuch
	bmi menu
foundmen	txa
	asl
	tax
	lda menuadr,x
	sta goto+1
	lda menuadr+1,x
	sta goto+2
goto	jsr 0
	jmp menu
exit	pla
	pla
	sei
	lda oldirq
	ldy oldirq+1
	sta irqvec
	sty irqvec+1
	cli
	jmp cint
restart	pla
	pla
	jmp begin
makekonf	ldx konfig
	inx
	txa
	and #$7
	ora #48
	sta konfig
	jsr adrout
	jmp copyto
swmode	lda mode
	eor #16
	sta mode
	rts
plus	lda mem+1
	clc
	adc #8
fertig	sta mem+1
	jsr adrout
	jmp copyto
minus	lda mem+1
	sec
	sbc #8
	jmp fertig
invall	ldy #0
	sty tmp
	lda #48
	sta tmp+1
	ldx #8
iall	lda (tmp),y
	eor #-1
	sta (tmp),y
	iny
	bne iall
	inc tmp+1
	dex
	bne iall
	rts
make2	ldx #4
	ldy #0
	sty tmp
	sty tmp2
	lda #48
	sta tmp+1
	lda #52
	sta tmp2+1
ma2	lda (tmp),y
	eor #-1
	sta (tmp2),y
	iny
	bne ma2
	inc tmp+1
	inc tmp2+1
	dex
	bne ma2
	rts
pbyt	inc mem
	bne ppbyt
	inc mem+1
ppbyt	jsr adrout
	jmp copyto
mbyt	lda mem
	bne mmbyt
	dec mem+1
mmbyt	dec mem
	jmp ppbyt
getname	lda #<namtxt
	ldy #>namtxt
	jsr strout
	ldx #3
	stx key
copybuf	lda buftxt-1,x
	sta keybuf-1,x
	dex
	bne copybuf
	ldx #0
namein	jsr input
	cmp #13
	beq cer
	sta filename,x
	inx
	cpx #16
	bcc namein
cer	txa
	ldx #<filename
	ldy #>filename
	jsr setnam
	ldx #8
	stx fa
	rts
load	jsr getname
	tax
	beq ret
	ldx #0
	txa
	ldy #48
	sta sa
	jsr loadr
	jmp init
ret	ldx #20
	jmp clrx
save	jsr getname
	tax
	beq ret
	ldx #0
	stx tmp
	ldy #48
	sty tmp+1
	ldy #56
	lda #tmp
	jsr saver
	jmp init
init	jsr cint
	lda #128
	sta keyrep
	lda #6
	sta vic+32
	sta vic+33
	ldx #216
	stx tmp+1
	ldx #4
	ldy #0
	sty tmp
colin	sta (tmp),y
	iny
	bne colin
	inc tmp+1
	dex
	bne colin
	lda #48
	sta konfig
	lda #0
	sta mem
	lda #48
	sta mem+1
	jsr copyto
	lda #200
	sta mode
	lda #0
	sta vic+34
	lda #12
	sta vic+35
	sei
	lda #zeile1
	sta vic+$12
	lda vic+$11
	and #$7f
	sta vic+$11
	lda #$81
	sta vic+$1a
	lda irqvec+1
	cmp #>testirq
	beq sat
	sta oldirq+1
	lda irqvec
	sta oldirq
	lda #<testirq
	ldy #>testirq
	sta irqvec
	sty irqvec+1
sat	cli
	lda #-1
	sta char
	lda #<1028
	ldy #>1028
	sta tmp
	sty tmp+1
	sta tmp2
	ldy #>55300
	sty tmp2+1
	ldx #8
	ldy #0
maketable	inc char
	lda #15
	sta (tmp2),y
	lda char
	sta (tmp),y
	iny
	cpy #32
	bcc maketable
	lda tmp
	clc
	adc #40
	sta tmp
	bcc noi1
	inc tmp+1
noi1	lda tmp2
	clc
	adc #40
	sta tmp2
	bcc noi2
	inc tmp2+1
noi2	ldy #0
	dex
	bne maketable
	lda #<met
	ldy #>met
	jsr strout
	jmp adrout
testirq	lda vic+$19
	sta vic+$19
	and #1
	bne okay
	lda ciaclr
	cli
	jmp (oldirq)
okay	lda vic+$12
	cmp #zeile2
	bcs second
	ldy #zeile2
	lda #29
	ldx mode
back	stx vic+22
	sty vic+$12
	sta vic+24
	jmp endirq
second	ldy #zeile1
	lda #21
	ldx #200
	bne back
strout	sta tmp
	sty tmp+1
sout	ldy #0
	lda (tmp),y
	bne weiter
	rts
weiter	cmp #"\x1a"
	bne nocr
	lda #13
nocr	cmp #"\x19"
	beq repeat
	cmp #"\x18"
	beq tab
	jsr bsout
in1	inc tmp
	bne sout
in2	inc tmp+1
	bne sout
repeat	iny
	lda (tmp),y
	tax
	iny
	lda (tmp),y
rep	jsr bsout
	dex
	bne rep
	lda tmp
	clc
	adc #3
	sta tmp
	bcc sout
	bcs in2
tab	lda #21
	sta spalte
	bne in1
adrout	lda #<adrline
	ldy #>adrline
	jsr strout
	lda konfig
	jsr hex1
	lda #15
	sta spalte
	lda mem+1
	jsr hexout
	lda mem
hexout	pha
	lsr
	lsr
	lsr
	lsr
	jsr hex1
	pla
hex1	and #15
	tax
	lda hexnum,x
	jmp bsout
copyto	lda mem
	ldy mem+1
	sta tmp
	sty tmp+1
	ldy #0
	sty tmp2
	lda #48
	sta tmp2+1
	ldx #8
	lda konf
	pha
	sei
	lda konfig
	sta konf
copy1	lda (tmp),y
	sta (tmp2),y
	dey
	bne copy1
	inc tmp+1
	inc tmp2+1
	dex
	bne copy1
	pla
	sta konf
	cli
	rts
